// CBitrateShape.h: interface for the CBitrateShape class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_CBITRATESHAPE_H__0B65F3A0_2492_4F6D_AA49_16E380984B1B__INCLUDED_)
#define AFX_CBITRATESHAPE_H__0B65F3A0_2492_4F6D_AA49_16E380984B1B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define PACKET_OVER_TCP		0
#define PACKET_OVER_UDP		1

class CBitrateShape
{
	friend DWORD WINAPI ThreadProc(LPVOID lpParameter);

public:
	CBitrateShape();
	virtual ~CBitrateShape();

	static double getExactTime();
	static int getLengthOfDataToSend(int prot, int packetSize);

	void setTargetBitrate(float fTargetKbps);
	void setTargetBitrate(int iTargetBPS);
	BOOL isItTimeToSendByUDP(int* pMillis, int packetSize);
	BOOL isItTimeToSendByTCP(int* pMillis, int packetSize);
	void countUDPPacketData(int packetSize);
	void countTCPPacketData(int packetSize);

protected:
	CRITICAL_SECTION cs;
	int iTargetBPS;
	double dLastTime;
	double dDataBufferedByNow;

	static int nHighResolutionTiming;
	static double dFrequency;
	static double dShapingWindowSize;

	BOOL isItTimeToSend(int* pMillis, int bytesToCount);
};

#endif // !defined(AFX_CBITRATESHAPE_H__0B65F3A0_2492_4F6D_AA49_16E380984B1B__INCLUDED_)
